editor: refactor editor state

Condense the content/history into a single dictionary.
Refactor the editor-changing/language-changing/example-loading code.
Result: lose ~75 lines of code (127->51).

[Of course my prior patch may have added that many.]