How to implement lines numeration like in IDE's, using multiline editable text box

I have problem with attachment numbers to multiline editable text box lines. I tried to add scroll box and synchronize it with text box, but it’s not working properly and I don’t think this is a solution. Is there a way to add number directly to the line, maybe override some functions in multiline editable text box class?