Commit graph

375 commits

Author SHA1 Message Date
Tim Culverhouse
bb277b8e37 window: fix word wrapping 2024-04-19 19:31:37 -08:00
Tim Culverhouse
cde945f2ef build: use std.Build.path 2024-04-19 16:22:46 -08:00
Tim Culverhouse
b93a5d2c72 window: change print return value to struct, add commit option
Return more information from `print`. Add `commit` option which does a
"dry run" of printing and returns the size of the wrapped text.
2024-04-19 16:12:52 -08:00
Tim Culverhouse
cda3e1de79 window: mark initChild and wrap as deprecated 2024-04-19 08:10:36 -08:00
Tim Culverhouse
bc206f8716 key: consume num_lock and caps_lock for keymatching
Consume num_lock before keymatching. consume caps_lock for most
keymatches, except for matchText, which will consume caps_lock as
needed.

Fixes: #19
2024-04-17 15:04:50 -08:00
Tim Culverhouse
3a928be693 window: export hasMouse
hasMouse should have been marked pub
2024-04-16 16:06:14 -08:00
Tim Culverhouse
606272f471 widgets: add initial nvim implementation 2024-04-16 16:06:14 -08:00
Tomasz Lisowski
a34d20541e Fix usage example in README 2024-04-16 09:50:43 -05:00
Tim Culverhouse
47160418aa api: export InternalScreen as AllocatingScreen
I'm not thrilled with the name but we'll go with it for now
2024-04-15 07:15:26 -05:00
Tim Culverhouse
7ff5251ea3 color: generate color from a u24 2024-04-15 07:15:00 -05:00
Tim Culverhouse
18609912d3 cursor: implement cursor shapes 2024-04-15 07:14:31 -05:00
Daylin Morgan
b5c2d80f57 build: add build flag for example 2024-04-11 10:39:01 -05:00
Tim Culverhouse
40f80bef0c build: change example to examples/text_input
Will add more example runs later
2024-04-10 14:40:22 -05:00
Tim Culverhouse
d3f22e7612 window: add hasMouse and scroll methods 2024-04-10 14:37:28 -05:00
Tim Culverhouse
e92498002e widgets(textinput): remove log line 2024-04-04 20:34:08 -05:00
Tim Culverhouse
310bff369b widgets(textinput): fix cursor positioning
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
2024-04-04 20:14:40 -05:00
Tim Culverhouse
770f6d1c07 parser: fix 0x0A decoding
0x0A should be decoded as Key.enter

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-04-03 19:38:06 -05:00
Tim Culverhouse
4118c5f8bc paste: fix bracketed_paste enabling
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-04-03 18:10:23 -05:00
Tim Culverhouse
8f53700302 key: fix evalquota for name_map 2024-04-03 12:25:34 -05:00
Tim Culverhouse
12ea1bb1e1 key: add name_map 2024-04-03 11:43:04 -05:00
Tim Culverhouse
6301fc6a0f build: add minimum_zig_version 2024-04-01 16:15:18 -05:00
Rylee Lyman
11564484ff fix: delete unused select.zig 2024-04-01 09:42:12 -05:00
Tim Culverhouse
ad18f346eb textinput: make byteOffsetToCursor public 2024-03-30 07:40:08 -05:00
Tim Culverhouse
24e8dccdca key: add isModifier method 2024-03-30 07:37:54 -05:00
Tim Culverhouse
ea6a4a714b widgets(textinput): add inserSliceAtCursor and sliceToCursor
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
2024-03-29 12:51:41 -05:00
Tim Culverhouse
da988cc8d9 readme: add link to docs page 2024-03-29 09:37:07 -05:00
Tim Culverhouse
910fac9cc2 docs: fix doc build step 2024-03-29 09:20:42 -05:00
Tim Culverhouse
117545ca4b window: add custom border location option
Add a way to draw borders in custom locations
2024-03-26 15:11:20 -05:00
Tim Culverhouse
6a31b71e33 widgets(textinput): properly reset state
Fix resetting of state when calling clearAndFree,
clearRetainingCapacity, or toOwnedSlice.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-26 09:01:07 -05:00
Tim Culverhouse
e37790904f update min zig version, readme 2024-03-21 19:29:26 -05:00
Tim Culverhouse
612e298d72 dep: update ziglyph
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-21 19:13:56 -05:00
Tim Culverhouse
740f83c07f dep: use upstream zigimg 2024-03-21 19:10:09 -05:00
Tim Culverhouse
5e1f9b17a5 window: add child method for cleaner child spawning 2024-03-21 13:54:49 -05:00
Tim Culverhouse
7e23a64aec mouse_shape: set state of last render properly 2024-03-20 10:21:48 -05:00
Tim Culverhouse
981909cce9 tty: remove unused quit_fd field 2024-03-19 13:41:01 -05:00
Tim Culverhouse
a505d67276 core: close read thread via DSR
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.
2024-03-19 13:41:01 -05:00
Tim Culverhouse
b0944234c6 widgets(textinput): add toOwnedSlice
Add a way to get the contents of the TextInput
2024-03-19 13:25:03 -05:00
Tim Culverhouse
d40fb7cbdb examples: clear textinput on enter 2024-03-19 13:24:17 -05:00
Tim Culverhouse
8a5fe1a8ab gwidth: fix gwidth for no_zwj case 2024-03-19 13:20:00 -05:00
Tim Culverhouse
15c64a0e66 textinput: implement horizontal scrolling
Scroll the textinput widget horizontally when it overflows either side.
2024-03-18 08:26:53 -05:00
Tim Culverhouse
f18f6328bb textinput: fix deleteToEnd
Fix behavior of deleteToEnd to delete the character underneath the
cursor to the end of the line.
2024-03-18 08:06:44 -05:00
Tim Culverhouse
8e76610617 fix: catch error on show_cursor 2024-03-17 19:26:42 -05:00
Tim Culverhouse
449eb170f7 fix: always show cursor on deinit
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
2024-03-17 09:17:42 -05:00
Rylee Lyman
9496270ecd fix: don't rely on std.time.microTimestamp() for accurate statistics
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.
2024-03-14 07:52:19 -05:00
Tim Culverhouse
1e5560cc09 textinput: add clear methods
Add clear methods to reset the underlying GapBuffer and reset cursor
positions

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-12 07:35:35 -05:00
Rylee Alanza Lyman
0798182012
feat: adds gap_buffer.zig for TextInput (#6)
Use a gap buffer for the `TextInput` widget instead of an `ArrayList`.
2024-03-12 06:38:23 -05:00
Tim Culverhouse
5e940fd295 print: continue on 0 width graphemes or words
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>
2024-03-11 19:01:43 -05:00
Tim Culverhouse
c5891399f1 api: export Screen and gwidth
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-03-11 09:38:52 -05:00
Tim Culverhouse
cecf774ed2 event: implement pollEvent and tryEvent
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>
2024-03-11 09:24:42 -05:00
Tim Culverhouse
22af4908a1 window: fix wrap method
The wrap method was returning a bool from the call to print. Fix this.
2024-03-10 07:48:01 -05:00