Line widgets could make drag-select break before. Closes #800
Huge refactor of lib/codemirror.js. Most code is now top-level (in the module wrapper function) rather than inside of the CodeMirror constructor sharing a huge amount of state. A CodeMirror instance now has (non-public) `display`, `view`, and `options` properties that describe its state. The display holds the editor's DOM structure and associated state, view represents a view on a document, containing `doc`, `sel`, `overwrite`, `scrollTop`, and `scrollLeft` properties. The `doc` itself contains its history. (It is not yet possible to switch views and documents in and out of an editor, but this does start clearing the way towards that.)
This makes the formatter easier to adjust to new mode, and cleans it up somewhat.
And move closetag over to it. This makes the code that gets the XML state out of the mode actually sound and extensible. Issue #820