Commit graph

306 commits

Author SHA1 Message Date
Tim Culverhouse
9dae256960 border: add right border
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-01 12:27:49 -06:00
Tim Culverhouse
cf71bb4e7c queue: fix thread safety
Fix thread safety with changes by leeward on IRC. leeward put this code
on sourcehut here: https://hg.sr.ht/~nmichaels/threadsafeq
2024-03-01 12:25:15 -06:00
Tim Culverhouse
dff38f84d1 border: fix all border limits 2024-02-28 16:14:55 -06:00
Tim Culverhouse
ba29a71b3b tty: change logged line to level debug 2024-02-27 07:44:59 -06:00
00JCIV00
e87d64a2b3 Added the table.zig example
- Created a basic user management example for the Table widget.
2024-02-26 19:27:56 -06:00
00JCIV00
923c81d7d2 widgets: added table widget
- 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.
2024-02-26 19:21:12 -06:00
00JCIV00
b57aab7040 Added the "matchesAny()" method to Keys 2024-02-26 19:21:12 -06:00
00JCIV00
70f1e3495c Changed log.info calls to log.debug for better release builds 2024-02-26 19:21:12 -06:00
00JCIV00
4a87c5f408 Added public Window declaration to main.zig 2024-02-26 19:21:12 -06:00
Tim Culverhouse
f84bad6420 tty: set termios ISIG = false and PARMRK = false
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.
2024-02-26 18:26:12 -06:00
Tim Culverhouse
9d87579076 key: remove duplicate match rule 2024-02-24 19:42:35 -06:00
Tim Culverhouse
d51530cb73 parser: don't encode tab and enter as ctrl+I and ctrl+m 2024-02-24 19:25:45 -06:00
Tim Culverhouse
981932debd queue: make public 2024-02-24 08:14:12 -06:00
Tim Culverhouse
0d730aba80 queue: update comments, add tryPop
Update comments on queue, and add a tryPop function which is nonblocking

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-02-19 10:11:18 -06:00
drust
6461e6719c Fixed the .len 2024-02-18 21:39:52 -06:00
Tim Culverhouse
8d0f73e951 gwidth: add no_zwj measurement method
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>
2024-02-18 12:26:23 -06:00
Tim Culverhouse
6418570819 update for zig-0.12.0-2809
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-02-18 12:20:47 -06:00
Jora Troosh
4a463cfa3a
refactor: make code more idiomatic
- 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});.
2024-02-11 12:59:33 -06:00
Tim Culverhouse
c99517181e queue: remove useless defer 2024-02-03 10:05:42 -06:00
Tim Culverhouse
62ee6d1b58 notify, setTitle: flush the buffer
Flush the buffer when calling notify and setTitle
2024-02-03 10:02:04 -06:00
Tim Culverhouse
eae1036c29 color: export Color and fix bright indexing
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-02-02 16:22:26 -06:00
Tim Culverhouse
2b8346f691 tty: shadow os.system with our own switch
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>
2024-02-02 11:14:25 -06:00
Tim Culverhouse
927b4120b5 tests: remove finished TODO
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 20:07:02 -06:00
Tim Culverhouse
a8e77a23ae keys: finish kitty key definitions
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 20:06:02 -06:00
Tim Culverhouse
3798a8ede3 window: implement wrap and introduce Segment type
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 19:13:56 -06:00
Tim Culverhouse
f3cf7bcfcd mouse: implement mouse parsing and events
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 12:50:00 -06:00
Tim Culverhouse
ad3ef19b87 mouse: add todo
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 07:31:27 -06:00
Tim Culverhouse
43f73eb895 image: implement deleting images from memory
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 07:18:16 -06:00
Tim Culverhouse
8c8c592722 parser: handle parsing of apc, sos, pm strings
This lets us detect kitty graphics.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-31 06:59:34 -06:00
Tim Culverhouse
23a00ede55 images: kitty support works well
We still need to handle querying for support.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-30 20:51:54 -06:00
Tim Culverhouse
ee85f49bde window: remove old import
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-30 18:23:05 -06:00
Tim Culverhouse
f901dde2a0 images: kitty image protocol works
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-30 16:26:35 -06:00
Tim Culverhouse
cc75fe6272 image: implement transmitting images
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-30 13:30:36 -06:00
Tim Culverhouse
626a9101bd images: move to subfolder, use union enum for implementations
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>
2024-01-30 07:14:34 -06:00
Tim Culverhouse
edb1fae2ab textinput: add more readline bindings
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-29 07:00:34 -06:00
Tim Culverhouse
96f7bd6044 cell: remove todo
Did this one already

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-28 22:45:37 -06:00
Tim Culverhouse
e6c8be4bd6 render: use provided character width
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>
2024-01-28 22:42:51 -06:00
Tim Culverhouse
a355d7519a fix name
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-28 21:36:30 -06:00
Tim Culverhouse
5c9ce93a63 update ziglyph
update ziglyph to include proper default text emoji with VS16 selector
widths

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-28 21:35:31 -06:00
Tim Culverhouse
c99dffaecf WIP: images
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-25 13:32:22 -06:00
Tim Culverhouse
8f311da873 vaxis: implement hyperlinks (osc8)
This requires additional allocations anytime there is a hyperlink

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 19:07:05 -06:00
Tim Culverhouse
9950c9eac5 vaxis: mode cleanup, initial mouse implementation
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 18:36:45 -06:00
Tim Culverhouse
85060b001f vaxis: implement mouse shapes
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 13:36:24 -06:00
Tim Culverhouse
4c84faddfa vaxis: implement bracketed paste
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 13:23:02 -06:00
Tim Culverhouse
400e2d5cac vaxis: implement osc2 set title
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 13:18:24 -06:00
Tim Culverhouse
33d43dc6d1 vaxis: implement osc9 and osc777 notifications
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 13:15:04 -06:00
Tim Culverhouse
35fcbd05d7 update example
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 10:20:00 -06:00
Tim Culverhouse
8d496ffcdd widgets(textinput): move key handling to ifelse block
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 09:54:22 -06:00
Tim Culverhouse
b57342726f parser: parse 0x08 as backspace
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 06:45:24 -06:00
Tim Culverhouse
1b83dfe652 fix: don't use sixel geometry query yet
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>
2024-01-24 06:25:45 -06:00
Tim Culverhouse
9f89ed06f3 vaxis: use vt caps to measure grapheme widths
Implement our own grapheme measuring function which switches on whether
the terminal supports mode 2027

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-24 06:12:39 -06:00
Tim Culverhouse
04f6117cfe vaxis: enable da1 parsing, use futex timeout to return from query
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>
2024-01-23 21:30:09 -06:00
Tim Culverhouse
a2dc97c039 vaxis: add mode 2027 query parsing, wcwidth measurement
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 21:06:02 -06:00
Tim Culverhouse
ef7b30dbee render: advance by width of grapheme
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 16:29:44 -06:00
Tim Culverhouse
aaa1c17a81 key: enable kitty keyboard
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 13:25:31 -06:00
Tim Culverhouse
44ff960cb0 caps: implement first capability response (kitty keyboard)
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 08:10:59 -06:00
Tim Culverhouse
59470f18e8 vaxis: add sync and refresh
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 07:36:44 -06:00
Tim Culverhouse
5d8f78ccd2 parser: return null events when unhandled
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 07:28:57 -06:00
Tim Culverhouse
8ac44bf3c9 key: implement better keymatching rules
This doesn't handle each case yet, I'm not certain that the rest of the
logic I have in go-vaxis is correct so I want to sit on it some more

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-23 06:35:56 -06:00
Tim Culverhouse
fd97fff931 text_input: add comment about ArrayList not being ideal
Siged-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 20:14:15 -06:00
Tim Culverhouse
d2f02897dc render: use different internal model of screen
We use two screens: one which the user provides a slice of bytes for the
graphemes, and the user owns the bytes. We copy those bytes to our
internal model so that we can compare between frames

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 20:09:35 -06:00
Tim Culverhouse
c9c704d4a7 render: fix when we set current cursor to new style, update examples
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 11:19:28 -06:00
Tim Culverhouse
70e0cafafe window: add hideCursor and showCursor
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 11:18:59 -06:00
Tim Culverhouse
f1a9e21a98 tty: use grapheme cache in the tty run method
We only need the grapheme cache when we are parsing input

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 10:40:30 -06:00
Tim Culverhouse
64557bf9ab parser: use a ring buffer to store raw text
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 10:26:33 -06:00
Tim Culverhouse
393279d978 queue: add tryPush method, a nonblocking push attempt
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-22 09:33:23 -06:00
Tim Culverhouse
5148d20f52 widgets: create an initial text_input and border widget
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 19:12:46 -06:00
Tim Culverhouse
558b64544c grapheme_cache: increase cache size
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 18:09:55 -06:00
Tim Culverhouse
40525eb038 parser: handle graphemes
I'm not positive this is the final approach. We fill in the `text` field
if there was multi-codepoint text generated from the key_press.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 17:54:44 -06:00
Tim Culverhouse
0f12881c17 parser: handle non-ascii input
But not full on graphemes, yet

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 16:11:51 -06:00
Tim Culverhouse
25d844702f tty: add events to parser handling, update comment
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 13:20:34 -06:00
Tim Culverhouse
8caa67d5b3 tty: add todo for incomplete parsing
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 13:16:52 -06:00
Tim Culverhouse
244ad8b68e parser: add unit tests
Test (nearly?) implementation so far

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 13:14:30 -06:00
Tim Culverhouse
4ac15e2195 parser: refactor into testable function
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 12:47:34 -06:00
Tim Culverhouse
38b41c4ecf parser: more kitty key parsing
Add some more implementation details to kitty key parsing

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 11:53:25 -06:00
Tim Culverhouse
5df727f77d key: assign certain keys to implicit kitty values
Kitty has implicit private area key values for certain keys. Let's just
use those in our definitions as well

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-21 11:52:10 -06:00
Tim Culverhouse
93d9ead99c parser: more progress on CSI parsing
Add additional CSI parsing for keys

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-20 08:05:22 -06:00
Tim Culverhouse
462a303903 examples: add some comments
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 22:02:10 -06:00
Tim Culverhouse
7c85f72e7f screen: move debug log
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 19:47:08 -06:00
Tim Culverhouse
de91cbe2d0 render: complete the render loop
This loop matches the go version of Vaxis to a tee. :chefs-kiss:

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 19:43:35 -06:00
Tim Culverhouse
13e9dadbb1 window: implement fill
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 13:16:53 -06:00
Tim Culverhouse
58bc6864cb render: implement double buffered screen for rendering
This lets us efficiently render by only updating cells that have changed
since last render

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 13:13:20 -06:00
Tim Culverhouse
1e7c82fe44 vaxis: fix casing of function name
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 12:39:42 -06:00
Tim Culverhouse
79b48e4dea queue: add comment
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 12:28:48 -06:00
Tim Culverhouse
43ea14e263 queue: check for fields before posting events
This allows users of the lib to not worry about having the fields on
their enum

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 12:24:02 -06:00
Tim Culverhouse
811fbdd2cb screen: refactor arg order and fix some math
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 12:21:14 -06:00
Tim Culverhouse
bef5276340 vaxis: send winsize at run, initialize screen to default cells
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 11:44:20 -06:00
Tim Culverhouse
08d2aae5fe cell: set default cell as a space of 1 width
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 11:02:32 -06:00
Tim Culverhouse
02bdcd7625 vaxis: adjust alt screen logic
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:59:47 -06:00
Tim Culverhouse
8c8caf4769 tty: enable writing to tty and add smcup in example
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:58:14 -06:00
Tim Culverhouse
76b2bf7bbc ctlseqs: add initial ctlseqs
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:42:05 -06:00
Tim Culverhouse
74d55aaa19 vaxis: fix window initialization
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:31:23 -06:00
Tim Culverhouse
959ae27c9f window: add some doc comments
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:21:49 -06:00
Tim Culverhouse
9029055de0 window: remove reference to parent
We don't need to keep references to the parent. We only need to
calculate offsets when we initialize a new window.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:17:11 -06:00
Tim Culverhouse
c3964fec43 rename project libvaxis
This is so similar to my vaxis project for go that we'll retain the name
here as well. The two can keep similar APIs and feature sets, but are
used in different languages. Maybe someday libvaxis will export a C api
for even broader use

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 10:13:32 -06:00
Tim Culverhouse
e1c042d5ae window: implement initial window data structure
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-19 06:48:10 -06:00
Tim Culverhouse
266c5ec224 screen: implement initial screen data structure
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 23:18:19 -06:00
Tim Culverhouse
a9c97d051b tty: implement winch handling
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 22:37:48 -06:00
Tim Culverhouse
3783bcad10 add cell, character, style, color primitives
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 21:03:09 -06:00
Tim Culverhouse
3176eb81ef hack: go to ground state in escape state
Only doing this until I finish the parser

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 20:35:33 -06:00
Tim Culverhouse
27548f7f9d parse: ground parser complete
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 20:30:42 -06:00
Tim Culverhouse
d22b2a89f3 chore: refactor build
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 20:17:26 -06:00
Tim Culverhouse
11b7b86913 core: functional App structure
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 19:02:59 -06:00
Tim Culverhouse
891bab73dd queue: add initial queue and app structure
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 16:16:21 -06:00
Tim Culverhouse
48362a307c tty: use simple os.read loop instead of xev
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-17 22:34:40 -06:00
Tim Culverhouse
b9564b7db8 initial commit
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-17 21:58:03 -06:00