Added function to enter/replace text at different cursor positions