I'm trying to create a text box which will have a limit of characters per line and creating new lines if this limit is reached. Right now I'm trying to loot at SelectionStart
in KeyUp
and determine if user is position where the he should go the next line then I'm just moving him to the next line until he'll reach a certain lines limit.
Logic for this is surprisingly complex. I have to look if I the last thing in the line is word and no separator in the end I need to move to the next line and merge with the next line and check if the next line isn't too long, etc. All of it isn't working all that well which is not a surprise. Plus too many manipulations with strings are as fast as I'd like to even using StringBuilder
.
Is there any easier way to do something like this?