Commit graph

520 commits

Author SHA1 Message Date
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
Tim Culverhouse
fb16eafdb6 vxfw: add Padding widget 2024-11-08 05:55:50 -06:00
Tim Culverhouse
147052b5f2 vxfw: add FlexRow widget 2024-11-08 05:55:50 -06:00
Tim Culverhouse
6941cd831c vxfw: add FlexColumn widget
FlexColumn is similar to a flexbox in HTML/CSS. It is a column that has
flexible height for it's children. It expands to fill the vertical space
2024-11-08 05:55:50 -06:00
Tim Culverhouse
96f5ec2a4e vxfw: add Button widget
Add the Button widget. Button reacts to mouse presses and the "enter"
key when it has focus
2024-11-08 05:55:50 -06:00
Tim Culverhouse
b64fa8c28a vxfw: add Center widget
Center widget centers a child widget within itself
2024-11-08 05:55:50 -06:00
Tim Culverhouse
cec9e5814f vxfw: add fuzzy finder example 2024-11-08 05:55:50 -06:00
Tim Culverhouse
118c5566d7 vxfw(App): fix vaxis import 2024-11-08 05:55:50 -06:00
Tim Culverhouse
de362ed7b6 vxfw: add TextField widget
Add the TextField widget. TextField is a single line user input field.
It supports onChange and onSubmit callbacks
2024-11-08 05:55:50 -06:00
Tim Culverhouse
e00950b800 vxfw: add ListView widget
Add the ListView widget. ListView is a scrollable list of widgets. It
has a cursor and mouse support.
2024-11-08 05:55:50 -06:00
Tim Culverhouse
11a829e140 vxfw: add RichText widget
RichText is a general purpose text layout widget which can have more
than one style. This comes with a small performance penalty compared to
`Text` due to not being able to do the same index operations, however it
does support all of the same features
2024-11-08 05:55:50 -06:00
Tim Culverhouse
b956154159 vxfw: add Text widget
Text widget is a general purpose text layout widget. Includes support
for soft wrapping, ellipsis truncation, and text alignment. A single
style is applied to the entire widget area.
2024-11-08 05:55:50 -06:00
Tim Culverhouse
bad7f9cab2 vxfw: add App runtime
Add the App runtime. App manages the event loop, focus, hit testing,
rendering, and scheduled events.
2024-11-08 05:55:50 -06:00
Tim Culverhouse
7cb04494b3 vxfw: introduce the vaxis framework
This was previously being developed at github.com/rockorager/vtk. I
really liked how it came together, and am moving it into the vaxis repo
piece by piece.
2024-11-08 05:55:50 -06:00
Tim Culverhouse
96f29a5fea window!: allow negative offsets and windows beyond screen
Allow negative offsets to a window. Allow a window to extend any edge of
the screen. Out-of-bounds cells ultimately don't write to the screen
2024-11-08 05:55:50 -06:00
Tim Culverhouse
22e55bdfec test: test Screen, skip TestTty on windows 2024-10-30 14:02:29 -05:00
Tim Culverhouse
6d98437434 core: fix panic handler 2024-10-30 13:14:39 -05:00
Tim Culverhouse
7fa04821c7 core: reset cursor and sgr in resetState
Move code to reset cursor and sgr state into `resetState` from `deinit`.

Fixes: #98
2024-10-30 11:40:40 -05:00
Tim Culverhouse
a228e3ea9b tty: move tty impls to common file 2024-10-30 11:15:35 -05:00
Tim Culverhouse
41a6de5f8c build: remove all build_options references 2024-10-30 11:05:03 -05:00
Tim Culverhouse
f1cad6da59 build!: make zigimg a required dependency
Require zigimg as a dependency. Remove build_options module, since we
have no more build options.
2024-10-30 10:49:06 -05:00
Tim Culverhouse
aaf1bb4784 core!: move libxev and zig-aio event loops to USAGE.md
Create USAGE.md to serve as a friendly guide for usage.

Move the libxev and zig-aio event loops to serve as an example of how to
implement a custom event loop in USAGE.md. Remove dependency on these
libraries and all associated examples and source code.

The motivation for this change is to provide a simpler library. The
power to create a custom event loop will always be kept, however the
support burden of maintaining three event loops is not where I want to
focus my energy. The code is small enough that it's easy enough to be
copy/pasted into a project or provided as a third-party library.
2024-10-30 10:38:25 -05:00
Tim Culverhouse
e29aca6b70 build: remove lint step
This step was unused. It was a format check step, but we instead run zig
fmt --check
2024-10-30 06:40:04 -05:00
Tim Culverhouse
9f1de42e8d tty: add test tty
This TestTTY is only valid on posix, for now. To get windows support we
will need to do a pipe or something on windows
2024-10-30 06:38:42 -05:00
Tim Culverhouse
0fd3f70ef1 zig fmt 2024-10-30 06:36:14 -05:00
Justin Braben
7df8ca616a
Add new alignment widgets (#96)
* Add new alignment widgets

* width and height now ?u16. (The limit does not exist!)
2024-10-23 11:06:48 -05:00
Tim Culverhouse
207103e652 window!: use nullable width and height
Use a nullable width and height when creating a child window

Fixes: #84
2024-10-21 11:51:25 -05:00
Tim Culverhouse
70238897bc all!: reduce usage of usize 2024-10-21 11:21:12 -05:00
Tim Culverhouse
cde1edf39d widgets!: remove border widget
The border widget functionality is replicated in Window.child
2024-10-21 10:21:45 -05:00
Danylo Kondratiev
142131595a widgets.TextView: add intCast 2024-10-16 15:40:55 -05:00