Text reflow woes (or: I want bullets back!)y
lel
lel at envs.net
Fri Jan 17 16:07:08 GMT 2020
On Fri, Jan 17, 2020 at 02:27:15PM +0000, solderpunk wrote:
> ...
> I guess the next thing to do is to start thinking about how
> difficult a "good enough" (not necessarily perfect) implementation of
> wrap_line_to_viewport is in most languages, and decide whether or not we
> think that burden is too high.
I don't think it's too high. I just wrote up an awful implementation in
the most naive way possible and it came out ~30 lines, with a good deal of
that being the edge case of words longer than the viewport width (i
handled this by splitting these words with hyphens at the viewport width;
i don't know if there are other edge-cases that need to be handled but i
can't think of any).
I'm attaching it. You can execute it with:
```
python3 wrap.py [length] [text]
```
Or import it and call wrap with first parameter being the text and the
second being the viewport width.
I can't stress enough how "not perfect" this is (I wrote it up on my
phone, of all things, in about 5 minutes, so very little thought was put
into making it good) but at the very least it's doable. I know you mention
that python can do this natively, but I didn't use any dynamic-typing, and
all that's required for this sort of implementation is a method to split
by newline and space, so really something like this could be done pretty
universally.
But it's still not good.
~ lel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrap.py
Type: text/x-python
Size: 1233 bytes
Desc: not available
URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200117/4becec65/attachment.py>
More information about the Gemini
mailing list