int insert_text(string text, int length, int pos)
Inserts text at a given position. Returns the position after the new text.