iced icon indicating copy to clipboard operation
iced copied to clipboard

Text content by cow

Open RamType0 opened this issue 2 years ago • 1 comments

#1050 Replace Text.content from String to Cow<'a,str> to reduce String allocation.

RamType0 avatar Nov 01 '21 15:11 RamType0

#1050 Replace Text.content from String to Cow<'a,str> to reduce String allocation.

I wounder if it's feasible to do alter TextInput message to be (String,TInputEvent) where TInputEvent contains various things that can happen with text input, like copy-paste events, char insertion at a position, etc.

Imagined API:

enum TInputEv {
   Paste( fn(&mut String) ), //this writes paste content to the string; when it's emmited message's `String` still contains old value
   Insertion{ at: Range<usize>, content: String} // range here indicates which indices of original string are going to be changed, content is payload; old value is still unchanged
  KeyPress(char) //technically a subset of previous, but this is so common that it deserves it's own variant, I think
}

tema3210 avatar Jun 11 '22 08:06 tema3210