Replies: 1 comment
|
The About the parsing thing. It looks like you're unhappy with the amount of time it takes to reparse these styles. Because everything is tied to only the rendering, the parsing actually happens every frame and can be split between different text render commands (for example if line wrapped): Lines 1958 to 2032 in 1e3b1c2 But the performance impact of that is probably really negligible. You are right tho that it doesn't quite seem efficient. From an API perspective, I like the idea that people could write their own parsers and stuff. I also like the idea of separating the regular I do not like your suggestion on "hooks" however. Hooks introduce quite a bit of complexity and callback overhead right inside the layout and rendering pipeline. Passing arbitrary functions into text rendering breaks everything and would be quite a mess. Instead allowing users to use custom parsers or (in 2.0 potentially using custom shaders), gives you all the flexibility you need. |
Uh oh!
There was an error while loading. Please reload this page.
I like very much Ply's philosophy and its simple yet expressive interface. In particular, I like the idea that Ply doesn't come with some hardwired stuff that makes the library unusable if you would want it differently. However, there is one exception to this: text styling.
I think the current state of affairs could be improved in three directions:
printfis bad with respect to Rust'sprintf:printf, it might lead to code sections which can be abused._. This looks to me more like a quick and dirty solution because it's easy to parse without a "real" parsing backing it.To solve these points, while keeping all the features that currently exist, I propose the following:
ui.text("..."),ui.texttake a type that already encodes how the text is parsed, and have a separateparsefunction that turns the text into that representation. The API would becomeui.text(parse("...")). At this point, one could also write it as a macro to avoid runtime parsing, which (besides the efficiency gain, which is probably negligible) prevents runtime styling injection.This way, the user is not tied to a particular string representation of text to be styled. For instance, I could be parsing and rendering Markdown, and I don't want to parse Markdown, then print it using Ply's syntax, then have Ply re-parse it.
{wave(speed = 3, amplitude = .3)|bla}(Python style), or{wave(speed: 3, amplitude: .3)|bla}(Typst style) or{(wave :speed 3 :amplitude .3)|bla}(Lisp style) or{wave speed=3 amplitude=.3|bla}(bash style) or{wave speed:3 amplitude:.3|bla}(OCaml style) or ... . One could even think of combining several styling at once, rather than nesting them, which is slightly more verbose than it needs to be: imagine{wave(speed = 3) pulse()|bla}(with whatever syntax you like better).I am open to suggestions. If this converges to a design that would be acceptable for Ply, I am willing to draft a working prototype, which would include all the features that I suggested here.
All reactions