Primrose is a lightweight text editor control with syntax highlighting and keyboard shortcuts for use in web browsers and WebGL projects. It draws directly to an HTML Canvas element. The resulting image can easily be used as a texture on 3D objects in a WebGL context. It is also extensible, providing a framework to support any number of programming languages, themes, and editing styles.
Check out Primrose Editor. Free for open source projects.