-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Prior to Bevy 0.15, this solution was necessary, because it was impossible to accurately determine the "physical" position of the cursor due to limitations in ab_glyph. (Er, seems that we're blocked on 0.16)
We should be able to do something less crazy for a cursor now.
We could either
-
Use
cosmic-text'sEditorfor cursor management (and buffer manipulation)The cosmic text design that landed in Bevy 0.15 didn't include a way to access the cosmic buffer. After Bevy 0.16, it might be possible to do this again thanks to CosmicBuffer is a public type but not not used or accessible in any public API bevyengine/bevy#17748.
This is arguably "not simple." and we may want to wait for improvements in cosmic-text. The buffer / editor juggling that needs to be done is pretty nasty. But it could potentially simplify other sections of code.
See cosmic changes #74 (comment)
And Save and resume editor state / handle external pop-os/cosmic-text#285. -
Look up the cursor position in
TextLayoutInfonow that it is more reliable.Note that
PositionedGlyph'ssizerefers to the size of the glyph texture, which is not what we want, especially for space characters.After Bevy 0.16, it will be possible to get the correct width value from the cosmic buffer. (though it is tedious to do so)
And draw the cursor as a simple colored Node. (This can/should be a temporary ExtractedNode in the render world)