Commit graph

29 commits

Author SHA1 Message Date
607c11fea4 Use new with_* naming scheme
All builder-like functions are now named with_*. There is also now a way
to set each property imperatively with only a mutable reference.

The only widgets I haven't yet converted to this style are the Join*
widgets; they're a bit harder to figure out an appropriate API for.
2023-02-20 15:53:49 +01:00
ba716dd089 Fix examples not measuring widths immediately 2023-02-18 20:13:47 +01:00
ba6ee45110 Don't measure widths while presenting 2023-02-17 18:59:32 +01:00
ac2546ba97 Add Terminal::{present_widget, present_async_widget} 2023-02-17 14:00:46 +01:00
ed14ea9023 Measure automatically in Terminal::present 2023-02-17 13:59:16 +01:00
845d88c93f Make widget example look slightly less horrible 2023-02-16 23:37:16 +01:00
9ff8007cae Switch usages of ContentStyle to Style 2023-02-16 21:24:52 +01:00
3f7e985b3f Add Background widget 2023-02-16 16:26:47 +01:00
575faf9bbf Add Float widget 2023-02-16 15:13:23 +01:00
bcc07dc9ba Add WidgetExt and AsyncWidgetExt traits 2023-02-16 15:12:33 +01:00
964f3bf011 Add Border widget 2023-02-16 14:30:06 +01:00
6a0c0474ec Add widget hello world example 2023-02-16 10:08:45 +01:00
4ffaae067e Export all types at top level 2023-02-16 09:37:31 +01:00
06aefd562b Remove wrap method from Frame 2022-09-26 17:34:38 +02:00
f258c84094 Expose Widthdb directly via Frame 2022-09-26 17:00:46 +02:00
26a8936cf5 Store Styled with contiguous string
The previous implementation of Styled used chunks that consisted of a
String and a ContentStyle. The current implementation instead stores a
single String and chunks consisting of a ContentStyle and an ending
index.

This implementation may reduce allocations and makes width-related
operations easier, for example getting the width of a Styled with its
whitespace trimmed.
2022-08-01 19:02:57 +02:00
11b2211fad Improve word wrapping
Now supports long trailing whitespace as well as tabs.
2022-07-04 19:38:28 +02:00
9b0d80873f Use styled chunks of text instead of plain strings 2022-07-04 19:38:28 +02:00
a0602a941c Fix examples 2022-06-15 14:02:30 +02:00
333cf74fba Make width measuring optional and disabled by default 2022-06-08 17:38:38 +02:00
33264b4aec Remove TODO 2022-05-29 13:18:39 +02:00
6b9e4cbc63 Ignore graphemes of width 0 when writing to buffer 2022-05-29 13:18:39 +02:00
37634139b0 Wrap text in a unicode-aware way 2022-05-29 13:18:39 +02:00
8fae7d2bf1 Return Redraw enum instead of bool
Boolean values were too easy to accidentally interpret the wrong way.
2022-05-29 13:18:25 +02:00
fe424b3376 Fix grapheme rendering
Previously, when overwriting wide graphemes, those were not first
cleared from the buffer. This could sometimes result in partial
graphemes, which is an invalid buffer state.

Now, when a wide grapheme is overwritten, it is removed from the buffer
entirely and replaced with spaces. Those spaces retain the style of the
removed grapheme.

A similar thing now happens with graphemes that only partially overlap
the buffer, either on the left or the right border. Those parts that are
inside the buffer are rendered as spaces with the grapheme's style.
2022-05-29 13:18:25 +02:00
9512ddaa3b Measure actual width of displayed characters 2022-05-29 13:18:25 +02:00
add2f25aba Use Frame for rendering instead of Buffer 2022-05-21 22:33:39 +02:00
cc2f102141 Position cursor via buffer 2022-05-21 21:07:24 +02:00
bbaea3b5bf Create simple terminal and buffer abstractions 2022-05-21 20:53:32 +02:00