Write a basic but functional text editor.