fubark / cosmic

A platform for computing and creating applications.
https://cosmic.ooo
MIT License
343 stars 16 forks source link

Text_demo 'Text Wrap' doesn't seem to work #29

Open wilsonk opened 2 years ago

wilsonk commented 2 years ago

Perhaps this is just on my machine (Arch linux distro), but the 'Text Wrap' toggle doesn't seem to actually wrap the example sentences in the demo window. The scroll bar across the bottom of the editor window appears if you make the font size larger but the sentence doesn't wrap.

There is also no wrap if you just start typing on application startup and type off the edge of the editor window.

fubark commented 2 years ago

Text wrapping is not implemented for the TextEditor widget yet. It does however work for the Text widget. Adding this feature to the TextEditor would involve additional computing for line positions so that the caret, mouse, and scrollview remains correct. The current logic for text layout is here for anyone interested: https://github.com/fubark/cosmic/blob/d6c0147bee067c23de88982022d85d467752a659/graphics/src/graphics.zig#L813

Since the TextEditor has a buffer for each line, the first version would probably need a TextLayout for each line. In the meantime, I'll update the demo with a todo item.