bevy_simple_text_input icon indicating copy to clipboard operation
bevy_simple_text_input copied to clipboard

cosmic changes

Open robtfm opened this issue 1 year ago • 4 comments

not to be merged as is, but in case it's useful as a starting point for you in the future.

here i have modifications to support bevy 0.14 with bevy#10193 (cosmic text) cherry picked in.

i added floating cursor, selection management, undo/redo and cut/copy/paste (on a feature flag for clipboard integration - it might be nice to allow some other non-system-clipboard support via resources/events but i don't need it personally).

still plan to add at least some mouse support (probably optional in settings).

robtfm avatar Aug 30 '24 13:08 robtfm

https://github.com/user-attachments/assets/0fce6a59-6fa0-4bb0-aa29-d984c6a9d462

robtfm avatar Aug 30 '24 13:08 robtfm

Lovely, thank you!

I was playing around with this a bit with https://github.com/rparrett/bevy_simple_text_input/tree/bevy_main as a base earlier, but really wasn't liking how it was going. I was referencing https://github.com/tigregalis/bevy_text_editor, but your implementation retaining an Editor seems way nicer.

rparrett avatar Aug 30 '24 13:08 rparrett

it does require copying the buffer (though using the lazy init, only when needed)... but it seems bevy does this internally for TextMeasures already, so maybe it's not so bad.

perhaps cosmic's BufferRef could be extended with a shared Arc<RwLock<Buffer>> variant as well, but i am not really willing to get into that at the moment.

robtfm avatar Aug 30 '24 13:08 robtfm

tigregalis had some ideas over here: https://github.com/pop-os/cosmic-text/issues/285

rparrett avatar Aug 30 '24 13:08 rparrett